﻿using System.Text.RegularExpressions;
using System.Windows.Media;
using Styx.Common;

namespace ChiWalker.Utilities
{
    public static class Logger
    {
        private static string _lastLogged;

        public static void Write(string message, params object[] args)
        {
            Write(Colors.Aquamarine, message, args);
        }

        public static void Write(Color clr, string message, params object[] args)
        {
            Write(LogLevel.Normal, clr, message, args);
        }

        public static void Write(LogLevel level, Color clr, string message, params object[] args)
        {
            string s = string.Format(message, args);
            if (_lastLogged == s) return;
            Logging.Write(level, clr, "[ChiWalker] " + message, args);
            _lastLogged = s;
        }

        public static void WriteVerbose(string message, params object[] args)
        {
            Write(LogLevel.Verbose, Colors.DarkCyan, message, args);
        }

        public static void WriteError(string message, params object[] args)
        {
            Write(LogLevel.Normal, Colors.Coral, message, args);
        }

        public static string SplitCamelCase(string str)
        {
            return Regex.Replace(Regex.Replace(str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
        }
    }
}